#ifndef _CONNDLG_H_
#define _CONNDLG_H_


#define ID_CONNDLG 10009
#define ID_LIST_SAVED 10022
#define ID_CONN_HOST 10011
#define ID_CONN_USER 10012
#define ID_CONN_PWD 10013
#define ID_CONN_PORT 10014
#define ID_CONN_DB 10015
#define ID_CONN_NAME 10000
#define ID_BT_CONN_SAVE 10023
#define ID_BT_CONN 10016
#define SYMBOL_CONNDLG_STYLE wxCAPTION|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL
#define SYMBOL_CONNDLG_TITLE _("Connection to MySQL")
#define SYMBOL_CONNDLG_IDNAME ID_CONNDLG
#define SYMBOL_CONNDLG_SIZE wxSize(400, 300)
#define SYMBOL_CONNDLG_POSITION wxDefaultPosition

#include "wx/xml/xml.h"
#include "wx/dynarray.h"
#include "wx/splitter.h"
#include "BLL/bll.h" 
#include "Control/MyUI.h"

class ConnDlg: public wxDialog
{    
    DECLARE_DYNAMIC_CLASS( ConnDlg )
    DECLARE_EVENT_TABLE()

public:
    ConnDlg();
    ConnDlg( wxWindow* parent, wxWindowID id = SYMBOL_CONNDLG_IDNAME, const wxString& caption = SYMBOL_CONNDLG_TITLE, const wxPoint& pos = SYMBOL_CONNDLG_POSITION, const wxSize& size = SYMBOL_CONNDLG_SIZE, long style = SYMBOL_CONNDLG_STYLE );
    ConnDlg( MYSQL* mysql, wxWindow* parent, wxWindowID id = SYMBOL_CONNDLG_IDNAME, const wxString& caption = SYMBOL_CONNDLG_TITLE, const wxPoint& pos = SYMBOL_CONNDLG_POSITION, const wxSize& size = SYMBOL_CONNDLG_SIZE, long style = SYMBOL_CONNDLG_STYLE );
	ConnDlg( ServerInfo* serverInfo, wxWindowID id = SYMBOL_CONNDLG_IDNAME, const wxString& caption = SYMBOL_CONNDLG_TITLE, const wxPoint& pos = SYMBOL_CONNDLG_POSITION, const wxSize& size = SYMBOL_CONNDLG_SIZE, long style = SYMBOL_CONNDLG_STYLE );

    bool Create( wxWindow* parent, wxWindowID id = SYMBOL_CONNDLG_IDNAME, const wxString& caption = SYMBOL_CONNDLG_TITLE, const wxPoint& pos = SYMBOL_CONNDLG_POSITION, const wxSize& size = SYMBOL_CONNDLG_SIZE, long style = SYMBOL_CONNDLG_STYLE );

    ~ConnDlg();

    void Init();

    void CreateControls();

    void OnListSavedSelected( wxCommandEvent& event );

    void OnBtConnSaveClick( wxCommandEvent& event );

    void OnConnectBtnClick( wxCommandEvent& event );

    wxBitmap GetBitmapResource( const wxString& name );

    wxIcon GetIconResource( const wxString& name );

    static bool ShowToolTips();

	wxString GetConnName(){ return conn_name->GetValue()==wxEmptyString ? lsSaved->GetLabel() : conn_name->GetValue() ; }


private:
    MYSQL* mysql;
    wxChoice* lsSaved;
    wxTextCtrl* conn_host;
    wxTextCtrl* conn_user;
    wxTextCtrl* conn_pwd;
    wxTextCtrl* conn_port;
    wxTextCtrl* conn_db;
    wxTextCtrl* conn_name;
	ServerInfo* serverInfo;
    ConfArray array;
};

#endif
